import { LoginAction } from '@/types/store'
import { getToken } from '@/utils/storage'

const initialState = getToken()

const login = (state = initialState, action: LoginAction) => {
  console.log(action)
  if (action.type === 'login/token') {
    return action.payload
  } else if (action.type === 'login/quit') {
    return { token: '', refresh_token: '' }
  }
  return state
}

export default login
